#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
int a[N], b[N];
int st[N][20], f[N];
int ans[N];
void init_st() {
  f[1] = 0;
  rep(i, 2, n * 2) f[i] = f[i >> 1] + 1;
  rep(i, 1, n * 2) st[i][0] = a[i];
  rep(j, 1, 17) {
    int len = 1 << j;
    rep(i, 1, n * 2 + 1 - len) {
      st[i][j] = max(st[i][j - 1], st[i + len / 2][j - 1]);
    }
  }
}
int query(int l, int r) {
  int len = r + 1 - l;
  int k = f[len];
  len = 1 << k;
  return max(st[l][k], st[r + 1 - len][k]);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 1, n) cin >> a[i];
  rep(i, 1, n) cin >> b[i];
  rep(i, 1, n) a[i + n] = a[i];
  init_st();
  rep(i, 1, n) {
    // search from left to right
    int l = i + 1, r = i + n - 1;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (query(i + 1, mid) >= b[i])
        r = mid - 1;
      else
        l = mid + 1;
    }
    int j = l;
    l = i + 1, r = i + n - 1;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (query(mid, i + n - 1) >= b[i])
        l = mid + 1;
      else
        r = mid - 1;
    }
    int k = r;
    ans[i] = min(j - i, i + n - k);
    if (ans[i] >= n) ans[i] = -1;
  }
  rep(i, 1, n) cout << ans[i] << ' ';
  return 0;
}